Left Termination of the query pattern mergesort_in_2(g, a) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof

Clauses:

mergesort([], []).
mergesort(.(E, []), .(E, [])).
mergesort(.(E, .(F, U)), V) :- ','(split(U, L2, L1), ','(mergesort(.(E, L2), X), ','(mergesort(.(F, L1), Z), merge(X, Z, V)))).
merge(X, [], X).
merge([], X, X).
merge(.(A, X), .(B, Y), .(A, Z)) :- ','(le(A, B), merge(X, .(B, Y), Z)).
merge(.(A, X), .(B, Y), .(B, Z)) :- ','(gt(A, B), merge(.(A, X), Y, Z)).
split([], [], []).
split(.(E, U), .(E, V), W) :- split(U, W, V).
gt(s(X), s(Y)) :- gt(X, Y).
gt(s(X), 0).
le(s(X), s(Y)) :- le(X, Y).
le(0, s(Y)).
le(0, 0).

Queries:

mergesort(g,a).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof
  ↳ PrologToPiTRSProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

MERGESORT_IN(.(E, .(F, U)), V) → U11(E, F, U, V, split_in(U, L2, L1))
MERGESORT_IN(.(E, .(F, U)), V) → SPLIT_IN(U, L2, L1)
SPLIT_IN(.(E, U), .(E, V), W) → U91(E, U, V, W, split_in(U, W, V))
SPLIT_IN(.(E, U), .(E, V), W) → SPLIT_IN(U, W, V)
U11(E, F, U, V, split_out(U, L2, L1)) → U21(E, F, U, V, L1, mergesort_in(.(E, L2), X))
U11(E, F, U, V, split_out(U, L2, L1)) → MERGESORT_IN(.(E, L2), X)
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U31(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → MERGESORT_IN(.(F, L1), Z)
U31(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U41(E, F, U, V, merge_in(X, Z, V))
U31(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → MERGE_IN(X, Z, V)
MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → U71(A, X, B, Y, Z, gt_in(A, B))
MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → GT_IN(A, B)
GT_IN(s(X), s(Y)) → U101(X, Y, gt_in(X, Y))
GT_IN(s(X), s(Y)) → GT_IN(X, Y)
U71(A, X, B, Y, Z, gt_out(A, B)) → U81(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
U71(A, X, B, Y, Z, gt_out(A, B)) → MERGE_IN(.(A, X), Y, Z)
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → U51(A, X, B, Y, Z, le_in(A, B))
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → LE_IN(A, B)
LE_IN(s(X), s(Y)) → U111(X, Y, le_in(X, Y))
LE_IN(s(X), s(Y)) → LE_IN(X, Y)
U51(A, X, B, Y, Z, le_out(A, B)) → U61(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
U51(A, X, B, Y, Z, le_out(A, B)) → MERGE_IN(X, .(B, Y), Z)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
U111(x1, x2, x3)  =  U111(x3)
SPLIT_IN(x1, x2, x3)  =  SPLIT_IN(x1)
MERGE_IN(x1, x2, x3)  =  MERGE_IN(x1, x2)
U51(x1, x2, x3, x4, x5, x6)  =  U51(x1, x2, x3, x4, x6)
U21(x1, x2, x3, x4, x5, x6)  =  U21(x2, x5, x6)
U91(x1, x2, x3, x4, x5)  =  U91(x1, x5)
U81(x1, x2, x3, x4, x5, x6)  =  U81(x3, x6)
LE_IN(x1, x2)  =  LE_IN(x1, x2)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x2, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)
U71(x1, x2, x3, x4, x5, x6)  =  U71(x1, x2, x3, x4, x6)
U101(x1, x2, x3)  =  U101(x3)
U41(x1, x2, x3, x4, x5)  =  U41(x5)
GT_IN(x1, x2)  =  GT_IN(x1, x2)
U61(x1, x2, x3, x4, x5, x6)  =  U61(x1, x6)
MERGESORT_IN(x1, x2)  =  MERGESORT_IN(x1)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

MERGESORT_IN(.(E, .(F, U)), V) → U11(E, F, U, V, split_in(U, L2, L1))
MERGESORT_IN(.(E, .(F, U)), V) → SPLIT_IN(U, L2, L1)
SPLIT_IN(.(E, U), .(E, V), W) → U91(E, U, V, W, split_in(U, W, V))
SPLIT_IN(.(E, U), .(E, V), W) → SPLIT_IN(U, W, V)
U11(E, F, U, V, split_out(U, L2, L1)) → U21(E, F, U, V, L1, mergesort_in(.(E, L2), X))
U11(E, F, U, V, split_out(U, L2, L1)) → MERGESORT_IN(.(E, L2), X)
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U31(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → MERGESORT_IN(.(F, L1), Z)
U31(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U41(E, F, U, V, merge_in(X, Z, V))
U31(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → MERGE_IN(X, Z, V)
MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → U71(A, X, B, Y, Z, gt_in(A, B))
MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → GT_IN(A, B)
GT_IN(s(X), s(Y)) → U101(X, Y, gt_in(X, Y))
GT_IN(s(X), s(Y)) → GT_IN(X, Y)
U71(A, X, B, Y, Z, gt_out(A, B)) → U81(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
U71(A, X, B, Y, Z, gt_out(A, B)) → MERGE_IN(.(A, X), Y, Z)
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → U51(A, X, B, Y, Z, le_in(A, B))
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → LE_IN(A, B)
LE_IN(s(X), s(Y)) → U111(X, Y, le_in(X, Y))
LE_IN(s(X), s(Y)) → LE_IN(X, Y)
U51(A, X, B, Y, Z, le_out(A, B)) → U61(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
U51(A, X, B, Y, Z, le_out(A, B)) → MERGE_IN(X, .(B, Y), Z)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
U111(x1, x2, x3)  =  U111(x3)
SPLIT_IN(x1, x2, x3)  =  SPLIT_IN(x1)
MERGE_IN(x1, x2, x3)  =  MERGE_IN(x1, x2)
U51(x1, x2, x3, x4, x5, x6)  =  U51(x1, x2, x3, x4, x6)
U21(x1, x2, x3, x4, x5, x6)  =  U21(x2, x5, x6)
U91(x1, x2, x3, x4, x5)  =  U91(x1, x5)
U81(x1, x2, x3, x4, x5, x6)  =  U81(x3, x6)
LE_IN(x1, x2)  =  LE_IN(x1, x2)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x2, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)
U71(x1, x2, x3, x4, x5, x6)  =  U71(x1, x2, x3, x4, x6)
U101(x1, x2, x3)  =  U101(x3)
U41(x1, x2, x3, x4, x5)  =  U41(x5)
GT_IN(x1, x2)  =  GT_IN(x1, x2)
U61(x1, x2, x3, x4, x5, x6)  =  U61(x1, x6)
MERGESORT_IN(x1, x2)  =  MERGESORT_IN(x1)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 5 SCCs with 11 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
PiDP
                ↳ UsableRulesProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

LE_IN(s(X), s(Y)) → LE_IN(X, Y)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
LE_IN(x1, x2)  =  LE_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

LE_IN(s(X), s(Y)) → LE_IN(X, Y)

R is empty.
Pi is empty.
We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

LE_IN(s(X), s(Y)) → LE_IN(X, Y)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
PiDP
                ↳ UsableRulesProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

GT_IN(s(X), s(Y)) → GT_IN(X, Y)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
GT_IN(x1, x2)  =  GT_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

GT_IN(s(X), s(Y)) → GT_IN(X, Y)

R is empty.
Pi is empty.
We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

GT_IN(s(X), s(Y)) → GT_IN(X, Y)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
PiDP
                ↳ UsableRulesProof
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → U71(A, X, B, Y, Z, gt_in(A, B))
U71(A, X, B, Y, Z, gt_out(A, B)) → MERGE_IN(.(A, X), Y, Z)
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → U51(A, X, B, Y, Z, le_in(A, B))
U51(A, X, B, Y, Z, le_out(A, B)) → MERGE_IN(X, .(B, Y), Z)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
MERGE_IN(x1, x2, x3)  =  MERGE_IN(x1, x2)
U51(x1, x2, x3, x4, x5, x6)  =  U51(x1, x2, x3, x4, x6)
U71(x1, x2, x3, x4, x5, x6)  =  U71(x1, x2, x3, x4, x6)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

MERGE_IN(.(A, X), .(B, Y), .(B, Z)) → U71(A, X, B, Y, Z, gt_in(A, B))
U71(A, X, B, Y, Z, gt_out(A, B)) → MERGE_IN(.(A, X), Y, Z)
MERGE_IN(.(A, X), .(B, Y), .(A, Z)) → U51(A, X, B, Y, Z, le_in(A, B))
U51(A, X, B, Y, Z, le_out(A, B)) → MERGE_IN(X, .(B, Y), Z)

The TRS R consists of the following rules:

gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))

The argument filtering Pi contains the following mapping:
.(x1, x2)  =  .(x1, x2)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
MERGE_IN(x1, x2, x3)  =  MERGE_IN(x1, x2)
U51(x1, x2, x3, x4, x5, x6)  =  U51(x1, x2, x3, x4, x6)
U71(x1, x2, x3, x4, x5, x6)  =  U71(x1, x2, x3, x4, x6)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPOrderProof
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

MERGE_IN(.(A, X), .(B, Y)) → U71(A, X, B, Y, gt_in(A, B))
U51(A, X, B, Y, le_out) → MERGE_IN(X, .(B, Y))
MERGE_IN(.(A, X), .(B, Y)) → U51(A, X, B, Y, le_in(A, B))
U71(A, X, B, Y, gt_out) → MERGE_IN(.(A, X), Y)

The TRS R consists of the following rules:

gt_in(s(X), 0) → gt_out
gt_in(s(X), s(Y)) → U10(gt_in(X, Y))
le_in(0, 0) → le_out
le_in(0, s(Y)) → le_out
le_in(s(X), s(Y)) → U11(le_in(X, Y))
U10(gt_out) → gt_out
U11(le_out) → le_out

The set Q consists of the following terms:

gt_in(x0, x1)
le_in(x0, x1)
U10(x0)
U11(x0)

We have to consider all (P,Q,R)-chains.
We use the reduction pair processor [15].


The following pairs can be oriented strictly and are deleted.


MERGE_IN(.(A, X), .(B, Y)) → U51(A, X, B, Y, le_in(A, B))
U71(A, X, B, Y, gt_out) → MERGE_IN(.(A, X), Y)
The remaining pairs can at least be oriented weakly.

MERGE_IN(.(A, X), .(B, Y)) → U71(A, X, B, Y, gt_in(A, B))
U51(A, X, B, Y, le_out) → MERGE_IN(X, .(B, Y))
Used ordering: Matrix interpretation [3]:
Non-tuple symbols:
M( le_out ) =
/1\
\1/

M( U10(x1) ) =
/0\
\0/
+
/00\
\01/
·x1

M( s(x1) ) =
/0\
\0/
+
/11\
\11/
·x1

M( 0 ) =
/1\
\0/

M( U11(x1) ) =
/0\
\0/
+
/11\
\01/
·x1

M( le_in(x1, x2) ) =
/0\
\0/
+
/11\
\11/
·x1+
/10\
\00/
·x2

M( .(x1, x2) ) =
/1\
\0/
+
/10\
\10/
·x1+
/10\
\01/
·x2

M( gt_out ) =
/0\
\1/

M( gt_in(x1, x2) ) =
/0\
\0/
+
/10\
\00/
·x1+
/00\
\10/
·x2

Tuple symbols:
M( U71(x1, ..., x5) ) = 1+
[1,0]
·x1+
[1,0]
·x2+
[0,0]
·x3+
[0,1]
·x4+
[0,1]
·x5

M( U51(x1, ..., x5) ) = 0+
[0,0]
·x1+
[1,0]
·x2+
[1,0]
·x3+
[0,1]
·x4+
[0,0]
·x5

M( MERGE_IN(x1, x2) ) = 0+
[1,0]
·x1+
[0,1]
·x2


Matrix type:
We used a basic matrix type which is not further parametrizeable.


As matrix orders are CE-compatible, we used usable rules w.r.t. argument filtering in the order.
The following usable rules [17] were oriented:

gt_in(s(X), s(Y)) → U10(gt_in(X, Y))
le_in(0, s(Y)) → le_out
U10(gt_out) → gt_out
gt_in(s(X), 0) → gt_out
le_in(0, 0) → le_out
U11(le_out) → le_out
le_in(s(X), s(Y)) → U11(le_in(X, Y))



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
                      ↳ QDP
                        ↳ QDPOrderProof
QDP
                            ↳ DependencyGraphProof
              ↳ PiDP
              ↳ PiDP
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

MERGE_IN(.(A, X), .(B, Y)) → U71(A, X, B, Y, gt_in(A, B))
U51(A, X, B, Y, le_out) → MERGE_IN(X, .(B, Y))

The TRS R consists of the following rules:

gt_in(s(X), 0) → gt_out
gt_in(s(X), s(Y)) → U10(gt_in(X, Y))
le_in(0, 0) → le_out
le_in(0, s(Y)) → le_out
le_in(s(X), s(Y)) → U11(le_in(X, Y))
U10(gt_out) → gt_out
U11(le_out) → le_out

The set Q consists of the following terms:

gt_in(x0, x1)
le_in(x0, x1)
U10(x0)
U11(x0)

We have to consider all (P,Q,R)-chains.
The approximation of the Dependency Graph [15,17,22] contains 0 SCCs with 2 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
PiDP
                ↳ UsableRulesProof
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

SPLIT_IN(.(E, U), .(E, V), W) → SPLIT_IN(U, W, V)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
SPLIT_IN(x1, x2, x3)  =  SPLIT_IN(x1)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

SPLIT_IN(.(E, U), .(E, V), W) → SPLIT_IN(U, W, V)

R is empty.
The argument filtering Pi contains the following mapping:
.(x1, x2)  =  .(x1, x2)
SPLIT_IN(x1, x2, x3)  =  SPLIT_IN(x1)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

SPLIT_IN(.(E, U)) → SPLIT_IN(U)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
PiDP
                ↳ UsableRulesProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

U11(E, F, U, V, split_out(U, L2, L1)) → U21(E, F, U, V, L1, mergesort_in(.(E, L2), X))
MERGESORT_IN(.(E, .(F, U)), V) → U11(E, F, U, V, split_in(U, L2, L1))
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → MERGESORT_IN(.(F, L1), Z)
U11(E, F, U, V, split_out(U, L2, L1)) → MERGESORT_IN(.(E, L2), X)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
U21(x1, x2, x3, x4, x5, x6)  =  U21(x2, x5, x6)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x2, x5)
MERGESORT_IN(x1, x2)  =  MERGESORT_IN(x1)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

U11(E, F, U, V, split_out(U, L2, L1)) → U21(E, F, U, V, L1, mergesort_in(.(E, L2), X))
MERGESORT_IN(.(E, .(F, U)), V) → U11(E, F, U, V, split_in(U, L2, L1))
U21(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → MERGESORT_IN(.(F, L1), Z)
U11(E, F, U, V, split_out(U, L2, L1)) → MERGESORT_IN(.(E, L2), X)

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x2, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out
U10(x1, x2, x3)  =  U10(x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x3, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out
U11(x1, x2, x3)  =  U11(x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x6)
merge_out(x1, x2, x3)  =  merge_out(x3)
U21(x1, x2, x3, x4, x5, x6)  =  U21(x2, x5, x6)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x2, x5)
MERGESORT_IN(x1, x2)  =  MERGESORT_IN(x1)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPOrderProof
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

U21(F, L1, mergesort_out(X)) → MERGESORT_IN(.(F, L1))
U11(E, F, split_out(L2, L1)) → U21(F, L1, mergesort_in(.(E, L2)))
MERGESORT_IN(.(E, .(F, U))) → U11(E, F, split_in(U))
U11(E, F, split_out(L2, L1)) → MERGESORT_IN(.(E, L2))

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U))) → U1(E, F, split_in(U))
mergesort_in(.(E, [])) → mergesort_out(.(E, []))
split_in(.(E, U)) → U9(E, split_in(U))
split_in([]) → split_out([], [])
U1(E, F, split_out(L2, L1)) → U2(F, L1, mergesort_in(.(E, L2)))
U9(E, split_out(W, V)) → split_out(.(E, V), W)
U2(F, L1, mergesort_out(X)) → U3(X, mergesort_in(.(F, L1)))
U3(X, mergesort_out(Z)) → U4(merge_in(X, Z))
U4(merge_out(V)) → mergesort_out(V)
merge_in(.(A, X), .(B, Y)) → U7(A, X, B, Y, gt_in(A, B))
merge_in(.(A, X), .(B, Y)) → U5(A, X, B, Y, le_in(A, B))
merge_in([], X) → merge_out(X)
merge_in(X, []) → merge_out(X)
U7(A, X, B, Y, gt_out) → U8(B, merge_in(.(A, X), Y))
U5(A, X, B, Y, le_out) → U6(A, merge_in(X, .(B, Y)))
gt_in(s(X), 0) → gt_out
gt_in(s(X), s(Y)) → U10(gt_in(X, Y))
U8(B, merge_out(Z)) → merge_out(.(B, Z))
le_in(0, 0) → le_out
le_in(0, s(Y)) → le_out
le_in(s(X), s(Y)) → U11(le_in(X, Y))
U6(A, merge_out(Z)) → merge_out(.(A, Z))
U10(gt_out) → gt_out
U11(le_out) → le_out

The set Q consists of the following terms:

mergesort_in(x0)
split_in(x0)
U1(x0, x1, x2)
U9(x0, x1)
U2(x0, x1, x2)
U3(x0, x1)
U4(x0)
merge_in(x0, x1)
U7(x0, x1, x2, x3, x4)
U5(x0, x1, x2, x3, x4)
gt_in(x0, x1)
U8(x0, x1)
le_in(x0, x1)
U6(x0, x1)
U10(x0)
U11(x0)

We have to consider all (P,Q,R)-chains.
We use the reduction pair processor [15].


The following pairs can be oriented strictly and are deleted.


U11(E, F, split_out(L2, L1)) → U21(F, L1, mergesort_in(.(E, L2)))
U11(E, F, split_out(L2, L1)) → MERGESORT_IN(.(E, L2))
The remaining pairs can at least be oriented weakly.

U21(F, L1, mergesort_out(X)) → MERGESORT_IN(.(F, L1))
MERGESORT_IN(.(E, .(F, U))) → U11(E, F, split_in(U))
Used ordering: Polynomial interpretation [25]:

POL(.(x1, x2)) = 1 + x2   
POL(0) = 1   
POL(MERGESORT_IN(x1)) = x1   
POL(U1(x1, x2, x3)) = 0   
POL(U10(x1)) = 1   
POL(U11(x1)) = 1   
POL(U11(x1, x2, x3)) = 1 + x3   
POL(U2(x1, x2, x3)) = 0   
POL(U21(x1, x2, x3)) = 1 + x2   
POL(U3(x1, x2)) = 0   
POL(U4(x1)) = 0   
POL(U5(x1, x2, x3, x4, x5)) = 0   
POL(U6(x1, x2)) = 0   
POL(U7(x1, x2, x3, x4, x5)) = 0   
POL(U8(x1, x2)) = 0   
POL(U9(x1, x2)) = 1 + x2   
POL([]) = 0   
POL(gt_in(x1, x2)) = x1 + x2   
POL(gt_out) = 1   
POL(le_in(x1, x2)) = x1 + x2   
POL(le_out) = 1   
POL(merge_in(x1, x2)) = 0   
POL(merge_out(x1)) = 0   
POL(mergesort_in(x1)) = 0   
POL(mergesort_out(x1)) = 0   
POL(s(x1)) = 1 + x1   
POL(split_in(x1)) = 1 + x1   
POL(split_out(x1, x2)) = 1 + x1 + x2   

The following usable rules [17] were oriented:

split_in(.(E, U)) → U9(E, split_in(U))
split_in([]) → split_out([], [])
U9(E, split_out(W, V)) → split_out(.(E, V), W)



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
                      ↳ QDP
                        ↳ QDPOrderProof
QDP
                            ↳ DependencyGraphProof
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

U21(F, L1, mergesort_out(X)) → MERGESORT_IN(.(F, L1))
MERGESORT_IN(.(E, .(F, U))) → U11(E, F, split_in(U))

The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U))) → U1(E, F, split_in(U))
mergesort_in(.(E, [])) → mergesort_out(.(E, []))
split_in(.(E, U)) → U9(E, split_in(U))
split_in([]) → split_out([], [])
U1(E, F, split_out(L2, L1)) → U2(F, L1, mergesort_in(.(E, L2)))
U9(E, split_out(W, V)) → split_out(.(E, V), W)
U2(F, L1, mergesort_out(X)) → U3(X, mergesort_in(.(F, L1)))
U3(X, mergesort_out(Z)) → U4(merge_in(X, Z))
U4(merge_out(V)) → mergesort_out(V)
merge_in(.(A, X), .(B, Y)) → U7(A, X, B, Y, gt_in(A, B))
merge_in(.(A, X), .(B, Y)) → U5(A, X, B, Y, le_in(A, B))
merge_in([], X) → merge_out(X)
merge_in(X, []) → merge_out(X)
U7(A, X, B, Y, gt_out) → U8(B, merge_in(.(A, X), Y))
U5(A, X, B, Y, le_out) → U6(A, merge_in(X, .(B, Y)))
gt_in(s(X), 0) → gt_out
gt_in(s(X), s(Y)) → U10(gt_in(X, Y))
U8(B, merge_out(Z)) → merge_out(.(B, Z))
le_in(0, 0) → le_out
le_in(0, s(Y)) → le_out
le_in(s(X), s(Y)) → U11(le_in(X, Y))
U6(A, merge_out(Z)) → merge_out(.(A, Z))
U10(gt_out) → gt_out
U11(le_out) → le_out

The set Q consists of the following terms:

mergesort_in(x0)
split_in(x0)
U1(x0, x1, x2)
U9(x0, x1)
U2(x0, x1, x2)
U3(x0, x1)
U4(x0)
merge_in(x0, x1)
U7(x0, x1, x2, x3, x4)
U5(x0, x1, x2, x3, x4)
gt_in(x0, x1)
U8(x0, x1)
le_in(x0, x1)
U6(x0, x1)
U10(x0)
U11(x0)

We have to consider all (P,Q,R)-chains.
The approximation of the Dependency Graph [15,17,22] contains 0 SCCs with 2 less nodes.
We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x3, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x2, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x1, x2, x3, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x1, x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x1, x2, x3, x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x1, x2, x3, x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out(x1, x2)
U10(x1, x2, x3)  =  U10(x1, x2, x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x1, x2, x3, x4, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out(x1, x2)
U11(x1, x2, x3)  =  U11(x1, x2, x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x2, x3, x4, x6)
merge_out(x1, x2, x3)  =  merge_out(x1, x2, x3)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
PiTRS

Pi-finite rewrite system:
The TRS R consists of the following rules:

mergesort_in(.(E, .(F, U)), V) → U1(E, F, U, V, split_in(U, L2, L1))
split_in(.(E, U), .(E, V), W) → U9(E, U, V, W, split_in(U, W, V))
split_in([], [], []) → split_out([], [], [])
U9(E, U, V, W, split_out(U, W, V)) → split_out(.(E, U), .(E, V), W)
U1(E, F, U, V, split_out(U, L2, L1)) → U2(E, F, U, V, L1, mergesort_in(.(E, L2), X))
mergesort_in(.(E, []), .(E, [])) → mergesort_out(.(E, []), .(E, []))
mergesort_in([], []) → mergesort_out([], [])
U2(E, F, U, V, L1, mergesort_out(.(E, L2), X)) → U3(E, F, U, V, X, mergesort_in(.(F, L1), Z))
U3(E, F, U, V, X, mergesort_out(.(F, L1), Z)) → U4(E, F, U, V, merge_in(X, Z, V))
merge_in(.(A, X), .(B, Y), .(B, Z)) → U7(A, X, B, Y, Z, gt_in(A, B))
gt_in(s(X), 0) → gt_out(s(X), 0)
gt_in(s(X), s(Y)) → U10(X, Y, gt_in(X, Y))
U10(X, Y, gt_out(X, Y)) → gt_out(s(X), s(Y))
U7(A, X, B, Y, Z, gt_out(A, B)) → U8(A, X, B, Y, Z, merge_in(.(A, X), Y, Z))
merge_in(.(A, X), .(B, Y), .(A, Z)) → U5(A, X, B, Y, Z, le_in(A, B))
le_in(0, 0) → le_out(0, 0)
le_in(0, s(Y)) → le_out(0, s(Y))
le_in(s(X), s(Y)) → U11(X, Y, le_in(X, Y))
U11(X, Y, le_out(X, Y)) → le_out(s(X), s(Y))
U5(A, X, B, Y, Z, le_out(A, B)) → U6(A, X, B, Y, Z, merge_in(X, .(B, Y), Z))
merge_in([], X, X) → merge_out([], X, X)
merge_in(X, [], X) → merge_out(X, [], X)
U6(A, X, B, Y, Z, merge_out(X, .(B, Y), Z)) → merge_out(.(A, X), .(B, Y), .(A, Z))
U8(A, X, B, Y, Z, merge_out(.(A, X), Y, Z)) → merge_out(.(A, X), .(B, Y), .(B, Z))
U4(E, F, U, V, merge_out(X, Z, V)) → mergesort_out(.(E, .(F, U)), V)

The argument filtering Pi contains the following mapping:
mergesort_in(x1, x2)  =  mergesort_in(x1)
.(x1, x2)  =  .(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x2, x3, x5)
split_in(x1, x2, x3)  =  split_in(x1)
U9(x1, x2, x3, x4, x5)  =  U9(x1, x2, x5)
[]  =  []
split_out(x1, x2, x3)  =  split_out(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6)  =  U2(x1, x2, x3, x5, x6)
mergesort_out(x1, x2)  =  mergesort_out(x1, x2)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x1, x2, x3, x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x1, x2, x3, x5)
merge_in(x1, x2, x3)  =  merge_in(x1, x2)
U7(x1, x2, x3, x4, x5, x6)  =  U7(x1, x2, x3, x4, x6)
gt_in(x1, x2)  =  gt_in(x1, x2)
s(x1)  =  s(x1)
0  =  0
gt_out(x1, x2)  =  gt_out(x1, x2)
U10(x1, x2, x3)  =  U10(x1, x2, x3)
U8(x1, x2, x3, x4, x5, x6)  =  U8(x1, x2, x3, x4, x6)
U5(x1, x2, x3, x4, x5, x6)  =  U5(x1, x2, x3, x4, x6)
le_in(x1, x2)  =  le_in(x1, x2)
le_out(x1, x2)  =  le_out(x1, x2)
U11(x1, x2, x3)  =  U11(x1, x2, x3)
U6(x1, x2, x3, x4, x5, x6)  =  U6(x1, x2, x3, x4, x6)
merge_out(x1, x2, x3)  =  merge_out(x1, x2, x3)